package com.leyou.sh.item.dto;

import com.leyou.sh.common.dto.BaseDTO;
import com.leyou.sh.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author balisong_fcs
 * @date 2020/12/28 22:40
 * @desc
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class SpuDetailDTO extends BaseDTO {
    private Long spuId;// 对应的SPU的id
    private String description;// 商品描述
    private String packingList;// 包装清单
    private String afterService;// 售后服务
    private String specification;// 规格参数

    public SpuDetailDTO(BaseEntity entity) {
        super(entity);
    }
    public static <T extends BaseEntity> List<SpuDetailDTO> convertEntityList(Collection<T> list){
        if(list == null){
            return Collections.emptyList();
        }
        return list.stream().map(SpuDetailDTO::new).collect(Collectors.toList());
    }
}
